<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 数据处理
      const str = `name=jack&age=20&gender=boy`;

      function strToObj(str) {
        const arr = str.split("&").map((el) => {
          return el.split("=");
        });
        return Object.fromEntries(arr);
      }

      console.log(strToObj(str)); //{name:'jack',age:20,gender:'boy'}
    </script>
  </body>
</html>
